package com.ibeeking.found.cop.b.rest.service.mq;

import com.ibeeking.found.cop.b.rest.service.*;
import com.ibeeking.found.cop.service.common.param.MqSyncCopParam;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

@Service
public class CopMessageConsumerHandler {

    @Resource
    private ICopSensitiveWordService copSensitiveWordServiceImpl;

    @Resource
    private IMsgGroupMassMessageService msgGroupMassMessageServiceImpl;

    @Resource
    private IMsgMassMessageService msgMassMessageServiceImpl;

    @Resource
    private IMsgMessageTaskService msgMessageTaskServiceImpl;

    @Resource
    private IMsgFansMomentService msgFansMomentServiceImpl;

    @Resource
    private IMsgFansMomentTaskService msgFansMomentTaskServiceImpl;

    public boolean addAndUpdateSensitiveWord(MqSyncCopParam mqParam, Map<String, Object> extMap) {
        Long tenantId = mqParam.getTenantId();
        Long msgId = mqParam.getId();
        String operType= mqParam.getOperType();
        copSensitiveWordServiceImpl.syncSensitiveWordToWxCp(tenantId.intValue(), msgId, false);
        return true;
    }
    public boolean delSensitiveWord(MqSyncCopParam mqParam, Map<String, Object> extMap) {
        Long tenantId = mqParam.getTenantId();
        Long msgId = mqParam.getId();
        String operType= mqParam.getOperType();
        copSensitiveWordServiceImpl.syncSensitiveWordToWxCp(tenantId.intValue(), msgId, true);
        return true;
    }

    public boolean sendGroupMassMessageToWxcp(MqSyncCopParam mqParam, Map<String, Object> extMap) {
        Long tenantId = mqParam.getTenantId();
        Long msgId = mqParam.getId();
        msgGroupMassMessageServiceImpl.sendGroupMassMessageToWxCp(tenantId.intValue(), msgId);
        return true;
    }

    public boolean cancelGroupMassMessageToWxcp(MqSyncCopParam mqParam, Map<String, Object> extMap) {
        Long tenantId = mqParam.getTenantId();
        Long msgId = mqParam.getId();
        msgGroupMassMessageServiceImpl.stopSendGroupMassMessageToWxCp(tenantId.intValue(), msgId);
        return true;
    }

    public boolean sendMassMessageToWxcp(MqSyncCopParam mqParam, Map<String, Object> extMap) {
        Long tenantId = mqParam.getTenantId();
        Long msgId = mqParam.getId();
        msgMassMessageServiceImpl.sendMassMessageToWxCp(tenantId.intValue(), msgId);
        return true;
    }

    public boolean cancelMassMessageToWxcp(MqSyncCopParam mqParam, Map<String, Object> extMap) {
        Long tenantId = mqParam.getTenantId();
        Long msgId = mqParam.getId();
        msgMassMessageServiceImpl.stopSendMassMessageToWxCp(tenantId.intValue(), msgId);
        return true;
    }

    public boolean notifyMassMessageTaskToWxcp(MqSyncCopParam mqParam, Map<String, Object> extMap) {
        Long tenantId = mqParam.getTenantId();
        Long msgId = mqParam.getId();
        msgMessageTaskServiceImpl.syncMessageNotifySenderTaskToWxCp(tenantId.intValue(), msgId);
        return true;
    }

    public boolean syncMessageSendRecordFromWxCp(MqSyncCopParam mqParam, Map<String, Object> extMap) {
        Long tenantId = mqParam.getTenantId();
        Long msgId = mqParam.getId();
        String chatType= mqParam.getChatType();
        String beginDate = mqParam.getBeginDate();;
        String endDate = mqParam.getEndDate();;
        msgMessageTaskServiceImpl.syncMessageSendRecordFromWxCp(tenantId.intValue(), chatType, beginDate, endDate);
        return true;
    }

    public boolean sendFansMomentToWxCp(MqSyncCopParam mqParam, Map<String, Object> extMap) {
        Long tenantId = mqParam.getTenantId();
        Long msgId = mqParam.getId();
        msgFansMomentServiceImpl.sendFansMomentToWxCp(tenantId.intValue(), msgId);
        return true;
    }

    public boolean syncFansMomentTaskRecordFromWxCp(MqSyncCopParam mqParam, Map<String, Object> extMap) {
        Long tenantId = mqParam.getTenantId();
        Long msgId = mqParam.getId();
        String beginDate = mqParam.getBeginDate();;
        String endDate = mqParam.getEndDate();;
        msgFansMomentTaskServiceImpl.syncFansMomentTaskRecordFromWxCp(tenantId.intValue(), beginDate, endDate);
        return true;
    }
    public boolean cancelFansMomentToWxCp(MqSyncCopParam mqParam, Map<String, Object> extMap) {
        Long tenantId = mqParam.getTenantId();
        Long msgId = mqParam.getId();
        msgFansMomentServiceImpl.stopSendFansMomentToWxCp(tenantId.intValue(), msgId);
        return true;
    }

}
